package com.itheima.chapter04.arraylist;

import java.util.ArrayList;

public class demo4 {
    public static void main(String[] args) {
        ArrayList<String> list =new ArrayList<>();
        list.add("abc");
        list.add("123");
        list.add("345");
        list.add("567");
        list.add("789");
        list.add("777");
        //删除指定元素
        boolean b1 =list.remove("abc");
        boolean b2 =list.remove("zzz");
        System.out.println(b1);
        System.out.println(b2);
        System.out.println(list);
        //删除指定索引处元素
        String s = list.remove(0);
        System.out.println(s);
        System.out.println(list);
        //修改指定索引处元素
        String s1 = list.set(0,"666");
        System.out.println(s1);
        System.out.println(list);
        //返回指定索引处元素
        String s2 = list.get(0);
        String s3 = list.get(1);
        System.out.println(s2);
        System.out.println(s3);
        //返回集合中元素个数
        int size = list.size();
        System.out.println(size);
    }

}
